var App = {
		FtpLibrary:null,
    initialize: function() {
        //If Backbone sync gets an unauthorized header, it means the user's
        //session has expired, so send them back to the homepage
        var sync = Backbone.sync;
        Backbone.sync = function(method, model, options) {
            options.error = function(xhr, ajaxOptions, thrownError) {
                if (xhr.status == 401) {
                    window.location = '/';
                }
            }
            sync(method, model, options);
        };        
        //new AppView({ el: $('body') });
        //Backbone.history.start({pushState: true});
        var self = this;
        $(window).resize(function() {
            self.resizeHeader();
        });
        this.resizeHeader();   
        //this.checkFtpLibrary();
    },
    resizeHeader: function() {
        setTimeout(function() {
            var el = $('#app div:first');
            if (el && el.offset()) {
                var left = el.offset().left;
                if (left > 132) left = 132;
                if (left < 20) left = 20;
                $('#redbar .wrap').css('margin-left', left + 'px');
                $('#redbar .wrap').css('margin-right', (left + 20) + 'px');
            }
        }, 1000);
    },
    checkFtpLibrary:function(){
        try{
        	App.FtpLibrary = document.getElementById('upLoad_FtpLibrary');
        	//alert(App.FtpLibrary.Version);
           if(!App.FtpLibrary.Version){
        	   //window.open("./common/activex/ftp_ocx_setup.exe","_self");
            }
           	if(App.FtpLibrary.Version && this.FtpLibrary.State){
           		App.FtpLibrary.Info="e$(m$(j+0u*.m&*j(,&lt;&nbsp;<br>      ";
           		App.FtpLibrary.SInfo="jckplintggitlfiljncnhowifstwifthipwn";
	          }
        }catch(e){
            alert("fnCheckFtpLibrary\n"+e.description);
        }
   },
   connectFtpServer:function(){
	   App.FtpLibrary.ServerName = "NEJFFAKFFKEGMEIKEGMEIKEGNEJ";
	   App.FtpLibrary.UserName = "MGGPHILIDKICIIAQHJKICLID";
	   App.FtpLibrary.PassWord = "NEJFFAGFBHFCIFDJFE";
	   App.FtpLibrary.RemotePort = "21";
	   if(App.FtpLibrary.Connect()){
		   //alert("链接成功");
		   return App.FtpLibrary;
	   }else{
		   alert("连接失败:\n" + this.FtpLibrary.ErrorInfo);
	   }
	   return null;
   }
};
